#ifndef VIDEOSURFACE_H
#define VIDEOSURFACE_H

#include <QAbstractVideoSurface>
#include <QList>
#include <QVideoFrame>


class videoSurface : public QAbstractVideoSurface
{

public:
    explicit videoSurface(QObject *parent = 0);
    ~videoSurface();
    QImage* getQImage();
    bool  present(const QVideoFrame &frame);
    QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle)const;

    static inline quint32 qYUVToARGB32(int y, int rv, int guv, int bu, int a = 0xff);

    static inline void planarYUV420_to_ARGB32(const uchar *y, int yStride,
                                              const uchar *u, int uStride,
                                              const uchar *v, int vStride,
                                              int uvPixelStride,
                                              quint32 *rgb,
                                              int width, int height);

private:
    void qt_convert_NV21_to_ARGB32(const QVideoFrame &frame, uchar *output);
    QImage img;
};


#endif // VIDEOSURFACE_H
